package lab01;

public class test12 {
    public static void main(String[] args) {
        System.out.println("回文判断");
        System.out.println("请输入一个在1到9999之间的数.");
        Scanner s = new Scanner(System.in);
        int num = s.nextInt();
        if (num >= 0 && num <= 9) {
            System.out.println("这个数是个位数.");
            System.out.println("这个数是回文.");
        } else if (num > 9 && num <= 99) {
            System.out.println("这个数是个十位数.");
            int a = num / 10;
            int b = num - a * 10;
            if (b * 10 + a == num) {
                System.out.println("这个数是回文");
            } else
                System.out.println("这个数不是回文.");

        } else if (num > 99 && num <= 999) {
            System.out.println("这个数是个百位数.");
            int a = num / 100;
            int b = (num - a * 100) / 10;
            int c = num - a * 100 - b * 10;
            if (c * 100 + b * 10 + c == num) {
                System.out.println("这个数是回文");
            } else
                System.out.println("这个数不是回文.");

        } else if (num > 999 && num <= 9999) {
            System.out.println("这个数是个千位数.");
            int a = num / 1000;
            int b = (num - a * 1000) / 100;
            int c = (num - a * 1000 - b * 100) / 10;
            int d = num - a * 1000 - b * 100 - c * 10;
            if (d * 1000 + c * 100 + b * 10 + a == num) {
                System.out.println("这个数是回文");
            } else
                System.out.println("这个数不是回文.");
        } else if (num > 9999 | num < 0) {
            System.out.println("此数超出范围 .");
        }
    }

}
